***********************Appendix***********************
* Appendix A: Comparison of Dependent Variable Measures in CFS and Teele (2022). 
	
* Appendix B. Demonstration of Change in Competition before and after PR 

* Appendix C. Supplemental Analyses of Relationship between Turnout and Competition
	*C.1: Raw data showing difference-in-means of change in gender gap across pre-PR competition
	*C.2: Raw data presenting difference-of-means for change in gender gap by party entry post-PR
	*C.3: Regressions of Women's and Men's Turnout with Different Measures of Competition
	
*Appendix D: Sample Selection Quesion: Examination of districts left out of the CFS sample.
	
*Appendix E: Does the Gender Gap Fall because of Labour Radicalization?
***********************Appendix***********************


cd "YOUR DIRECTORY HERE"


******************************
*Appendix A:   Comparison of Dependent Variable Measures 
******************************
* See "Comparison of DV.do" for comparison with CFS measure of turnout.

******************************
*Appendix B:  Demonstration of Change in Competition before and after PR 
******************************
use "CFS/Turnout_District_Level.dta", clear 

sort year PR_district
drop _merge
merge year PR_district using "CFS/AlternativeMargin.dta"
drop if _merge==2 /* PR-districts not in sample */


*compare same district margin before and after.

sort SMD_district year
gen premargin1918=margin[_n-1]
replace premargin1918=. if year!=1921

 
twoway (scatter min_distance premargin1918 if min_distance<=premargin1918) (scatter min_distance premargin1918 if min_distance>premargin1918, mcolor(red))   if year==1921, legend(label(1 "more competitive") label(2 "became less competitive") order(2 1) row(1)) xtitle("Margin of Victory, 1918" "more competitive                                                    less competitive") ytitle("Margin 1921") scheme(tufte) 

graph export "../images/FigA5.eps", replace



************************************************
*Appendix C1: Raw data showing difference-in-means of change in gender gap across pre-PR competition
*************************************************
use "CFS/Turnout_District_Level_ladies.dta", clear 

gen did=ch_turnoutwomen-ch_turnoutmen


drop SMD_margin_quantile
xtile SMD_margin_quantile=SMD_margin, nq(6)

graph box did if year==1921, over(SMD_margin_quantile) title("Change in Gender Gap by Pre-Reform Competition") subtitle("Most Competitive                      Least Competitive") ytitle("Change in Women's Turnout - Change in Men's ") graphregion(fcolor(white)) scheme(tufte) legend(off) 

graph export "../images/FigA6.eps", replace

*T-test for diff in means of diff-in-diff for quantile 1 and 6. 
*Did women's participation increase by more than men's in the previously less competitive districts (Q6)? than in Q1?  Ha: diff < 0   
ttest did if inlist(SMD_margin_quantile, 1, 6) & year==1921, by(SMD_margin_quantile)
*p=.003



******************************************************
*Appendix C2: Raw data presenting difference-of-means for change in gender gap by party entry post-PR
******************************************************

use "CFS/Turnout_District_Level_ladies.dta", clear 
gen zz=1
*merge with pre-reform number of parties 

capture drop _merge
sort year SMD_district
merge 1:1 SMD_district year using "CFS/NoP_pre.dta"


foreach year in 1921 1924 1927 {
cap drop _merge
sort year PR_district
merge m:1 PR_district year using "CFS/NoP`year'.dta", update
}

keep if zz==1 /* 92 districts with data pre and post reform */

bysort year: egen mean_NoP=mean(NoP)
label var mean_NoP "Number of Parties Running"
label var NoP "Number of Parties Running"

*Change in gender gap 
gen did=ch_turnoutwomen-ch_turnoutmen

*Change in number of parties

sort SMD_district year
gen NoP1918=NoP[_n-1]
replace NoP1918=. if year!=1921

gen ch_NoP=NoP-NoP1918 if year==1921

graph box did if year==1921, over(ch_NoP) title("Change in Women's Turnout - Change in Men's") subtitle("Change in Number of Parties 1921-1918") ytitle("Change in the Gender Gap")  graphregion(fcolor(white)) scheme(tufte) legend(off) 

graph export "../images/FigA7.eps", replace

ttest did if inlist(ch_NoP, 0, 4) & year==1921, by(ch_NoP) /*no
 difference*/ 
 *p=.52
 


****************************************************
*Appendix C3: Regression of change in women's and men's turnout with different measures of competition
****************************************************

sort year PR_district
cap drop _merge
merge year PR_district using "CFS/AlternativeMargin.dta"
drop if _merge==2 /* PR-districts not in sample */

sort SMD_district year
gen premargin1918=SMD_margin_pre[_n-1]
replace premargin1918=. if year!=1921

*higher margin means less competitive. "Field" option of the rank command Rank assigns a 1 to the highest value. So using field means highest rank=most competitive
egen comprank1918=rank(premargin1918) if year==1921, field
egen comprank1921=rank(min_distance1) if year==1921, field 
scatter comprank1921 comprank1918

gen ch_comp=comprank1921-comprank1918 if year==1921


gen Margin=SMD_margin_pre
gen Margin2=SMD_margin_pre^2

tab PR_district, gen(d_PR_district)

egen avgmin_distance=mean(min_distance) if inlist(year, 1921,1927), by(PR_district)

gen ch_margin=avgmin_distance-Margin

gen ch_women100=ch_turnoutwomen*100
gen ch_men100=ch_turnoutmen*100

la var ch_comp "Change in Rank" 
la var premargin1918 "Average Margin Pre-PR" 
la var comprank1921 "Rank of Competition 1921" 
la var min_distance "Margin of last seat 1921" 
la var ch_NoP "Change Number of Parties" 

eststo clear
 
eststo: reg ch_women100 ch_comp if year==1921, robust
eststo: reg ch_men100 ch_comp if year==1921, robust

eststo: reg ch_women100  premargin1918 if year==1921, robust
eststo: reg ch_men100 premargin1918 if year==1921, robust

eststo: reg ch_women100 ch_NoP if year==1921, robust
eststo: reg ch_men100 ch_NoP if year==1921, robust

eststo: reg ch_women100  comprank1921 if year==1921, robust
eststo: reg ch_men100  comprank1921 if year==1921, robust

eststo: reg ch_women100  min_distance if year==1921, robust
eststo: reg ch_men100  min_distance if year==1921, robust

*esttab using "../images/Nor_reg.tex", star(+ 0.10 * 0.05** 0.01 ***0.001) replace cells(b(fmt(3)) se(par fmt(3))) r2 staraux   nodepvars mtitles("W" "M" "W" "M" "W" "M" "W" "M" "W" "M") label note("Dependent Variable is the Percentage point change in turnout for either women ``W'' or men ``M''. These have been scaled to make coefficients legible. Heteroskedasticty robust standard errors.")

esttab

*With cluster robust SE clustering on 22 PR districts. 

eststo clear
 
eststo: reg ch_women100 ch_comp if year==1921, cluster(PR_district)
eststo: reg ch_men100 ch_comp if year==1921, cluster(PR_district)

eststo: reg ch_women100  premargin1918 if year==1921, cluster(PR_district)
eststo: reg ch_men100 premargin1918 if year==1921, cluster(PR_district)

eststo: reg ch_women100 ch_NoP if year==1921, cluster(PR_district)
eststo: reg ch_men100 ch_NoP if year==1921, cluster(PR_district)

eststo: reg ch_women100  comprank1921 if year==1921, cluster(PR_district)
eststo: reg ch_men100  comprank1921 if year==1921, cluster(PR_district)

eststo: reg ch_women100  min_distance if year==1921, cluster(PR_district)
eststo: reg ch_men100  min_distance if year==1921, cluster(PR_district)

*esttab using "../images/Nor_reg_clusterSE.tex", star(+ 0.10 * 0.05** 0.01 ***0.001) replace cells(b(fmt(3)) se(par fmt(3))) r2 staraux   nodepvars mtitles("W" "M" "W" "M" "W" "M" "W" "M" "W" "M") label note("Dependent Variable is the Percentage point change in turnout for either women ``W'' or men ``M''. These have been scaled to make coefficients legible. Standard errors clustered at level of PR district.")

esttab


eststo clear
 
eststo: reg ch_women100 ch_comp if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))

eststo: reg ch_men100 ch_comp if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))


eststo: reg ch_women100  premargin1918 if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))
eststo: reg ch_men100 premargin1918 if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))


eststo: reg ch_women100 ch_NoP if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))

eststo: reg ch_men100 ch_NoP if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))


eststo: reg ch_women100  comprank1921 if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))

eststo: reg ch_men100  comprank1921 if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))


eststo: reg ch_women100  min_distance if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))

eststo: reg ch_men100  min_distance if year==1921, cluster(PR_district) vce(bootstrap, reps(100) seed(5))


esttab using "./images/Nor_reg_bootstrap.tex", star(+ 0.10 * 0.05** 0.01 ***0.001) replace cells(b(fmt(3)) se(par fmt(3))) r2 staraux   nodepvars mtitles("W" "M" "W" "M" "W" "M" "W" "M" "W" "M") label note("Dependent Variable is the Percentage point change in turnout for either women ``W'' or men ``M''. These have been scaled to make coefficients legible. Bootstrapped standard errors clustered at level of PR district.")


**The significance does not change whether the SEs are robust, clustered, or bootstrapped at the level of the PR district. 


************************************************************************
*Appendix D: Considerations of districts left out of the CFS sample; 
*Sample Selection Questions when Pre-reform District Structure could not be Matched
************************************************************************

************************************************************************
*Fig A8* Turnout of Women and Men in Included Urban Areas Mirrors Turnout in Excluded Urban Areas. 
************************************************************************

use "CFS/Turnout_District_Level_Before_Collapse.dta", clear /*the "Before_Collapse" data set has not dropped unused districts. The women's participation data is at the constituency level. CFS did not record this information for the unused constituencies (e.g. large municipalities that housed multiple SMDs, so I'll add that in later.)*/  

*Based on descriptions in Turnout_District_Level.do from Cox et al.'s paper, I define the type of municipality. 1s are included and 2s and 3s are excluded. 
drop type 
gen type=.
la define type 1 "Included" 2 "Large Muni, Multiple SMDS" 3 "Added reshuffled Municipalities or split over PR districts " 

*Type 2
*There are 6 Large municipalities that have multiple SMD districts. 
*The municipality number in the original electoral registers is different from the number CFS use. The original numbers are as follows: 
* oslo (5 districts) knr=301, drammen (2 districts) knr=602, kristiansand (2 districts) knr=1001, stavanger (2 districts) knr=1103, bergen (4 districts) knr=1301, trondheim (4 districts) knr=1601 

*In their dataset, CFS add an additional zero in the middle of the large munis knr number and then they drop them. they appear as oslo 3001-3005, kristiansand 10001-10002, drammen 6001, 6002, bergen 13001-13004, trondheim 16001-16004, and 11001 11002 Stavenger.

replace type=2 if inlist(knr, 3001, 3002, 3003, 3004, 3005) /*Oslo*/ 
replace type=2 if inlist(knr, 6001, 6002) /*Drammen*/
replace type=2 if inlist(knr, 10001, 10002)  /*kristiansand*/ 
replace type=2 if inlist(knr,11001, 11002) /*Stavenger*/ 
replace type=2 if inlist(knr,13001, 13002, 13003, 13004) /*Bergen*/ 
replace type=2 if inlist(knr,16001, 16002, 16003, 16004) /*Trondheim*/


*Type 3 Based on CFS's coding of reshuffled municipalities. 
replace type=3 if inlist(knr, 126, 213, 222) /*  municipality reshuffled */
replace type =3 if SMD_district<100 /* these are the municipalities split over multiple PR districts post-reform */

replace type=3 if inlist(valgkrets, 400, 490, 500, 1501-1506, 1901-1904) /* Lillehammer, Hamar, Gj¯vik og Kongsvinger delt i to *//* extra district was added in Romsdal, and then municipalities appear to be reshuffled from 1915 to 1918 *//* extra district was added in Troms, and then municipalities appear to be slightly reshuffled from 1915 to 1918 */
replace type=3 if knr==1280 /* aarstad part of Bergen from 1.7.1915 */
replace type=3 if inlist(SMD_district, 690, 892) /* h¯nefoss and notodden belongs to different post-reform districts (and counties) */ /* brevik and holmestrand belongs to different post-reform districts (and counties) */

recode type .=1
la val type type
tab type 
collapse (mean) turnoutwomen_final_pre turnoutmen_final_pre turnoutoverall_final_pre (firstnm) type city, by(SMD_district year)

keep if year<=1918

*included, rural
graph bar  turnoutwomen_final_pre turnoutmen_final_pre turnoutoverall_final_pre if type==1 & city!=1 & turnoutwomen<=1 & turnoutmen<=1 , over(year) scheme(s1mono) legend(label(1 "Women") label(2 "Men") label(3 "Total") row(1)) title("Included, Rural") name(g1, replace) blabel(bar, position(inside) format(%9.1f) color(white))  

*included, urban
graph bar  turnoutwomen_final_pre turnoutmen_final_pre turnoutoverall_final_pre if type==1 & city==1 & turnoutwomen<=1 & turnoutmen<=1  , over(year) scheme(s1mono) legend(label(1 "Women") label(2 "Men") label(3 "Total") row(1)) title("Included, Urban") name(g2, replace) blabel(bar, position(inside) format(%9.1f) color(white))  


*not included, urban. Note that this data was not available in CFS's storting constituency level dasets so had to be gathered from the electoral roll books. 

preserve 
clear 

input munic	year	turnoutwomen_final_pre	turnoutmen_final_pre	turnoutoverall_final_pre
301	1909	.6270404	.6550831	.6421067
301	1912	.6480371	.6533915	.6508703
301	1915	.6045654	.6910104	.6401401
602	1909	.7496622	.7526858	.7514958
602	1912	.8036059	.6978932	.7389619
602	1915	.7266055	.8051363	.7610171
1001	1909	.871188	.8072935	.8354025
1001	1912	.9297225	.84716	.8830512
1001	1915	.7509892	.7863501	.7676302
1103	1909	.7785425	.7383599	.7554751
1103	1912	.9023424	.8351998	.8658142
1103	1915	.7316937	.7215819	.727311
1301	1909	.7611481	.7387064	.7487773
1301	1912	.7031238	.6975567	.7000796
1301	1915	.6881811	.7342511	.7075835
1601	1909	.7544861	.7213365	.7351978
1601	1912	.6860777	.6798072	.6825446
1601	1915	.6547354	.6951061	.6719514
1701	1909	.7873303	.8304498	.8117647
1701	1912	.7596899	.8640777	.8165785
1701	1915	.7555556	.9032258	.8157895
301	1918	.6202429	.7327645	.6672968
602	1918	.6506919	.790954	.7115527
1001	1918	.7144482	.7712166	.7390856
1103	1918	.7153944	.7837262	.7440004
1301	1918	.654571	.7538707	.6965829
1601	1918	.6310587	.7072157	.6638179
1701	1918	.7665953	.9090909	.8232258


end


graph bar  turnoutwomen_final_pre turnoutmen_final_pre turnoutoverall_final_pre , over(year) scheme(s1mono) legend(label(1 "Women") label(2 "Men") label(3 "Total") row(1)) title("Excluded, Urban") name(g3, replace) blabel(bar, position(inside) format(%9.1f) color(white))  

restore

grc1leg g1 g2 g3, scheme(tufte)

graph export  "../images/FigA8.eps", replace





************************************************************************
*Fig A9* The change in competitiveness in PR- districts not included in our analysis (red
* line) mirrors the change in competitiveness in districts that are included post reform.
************************************************************************
use "CFS/Turnout_District_Level.dta", clear 
sort year PR_district
drop _merge
merge m:1 year PR_district using "CFS/AlternativeMargin.dta"

gen notinstudygroup=1 if _merge==2 /* PR-districts not in sample */
recode notin .=0

# delimit ; 
twoway 
(kdensity margin if year<1920 & notin!=1, lwidth(vthick)) 
(kdensity margin if year<1920 & notin==1, lcolor(red) lwidth(vthick))  
(kdensity min_distance1 if year>1920 & year<1930  & notin!=1, lwidth(vthick)) 
(kdensity min_distance1 if year>1920 & year<1930  & notin==1, lcolor(red) lwidth(medthick)), ///
title("") xtitle("Margin" "most competitive  ->   least competitive", size(medlarge)) ytitle("") legend(off)  text(2.5 .4 "Pre-reform, 1909-1918", size(med)) text(18 .18 "Post-reform, 1921-1927", size(med)) xsca(titlegap(*10)) ///
plotregion(lcolor(white) ilcolor(white)) graphregion(fcolor(white)) scheme(tufte) ;
# delimit cr  

graph export  "../images/FigA9.eps", replace




************************************************************************
*Appendix E: Does the Gender Gap Fall because of Labour Radicalization?
************************************************************************

************************************************************************
*Fig A10, A11 Does Working Class radicalization explain the gender gap? Go back to the quantiles and think it through. 
************************************************************************



use "CFS/Turnout_District_Level_ladies.dta", clear 
drop SMD_margin_quantile
xtile SMD_margin_quantile=SMD_margin, nq(6)

foreach type in men women  {

bysort year SMD_margin_quantile: egen mean_turnout_`type'=mean(turnout`type'_DT)
label var mean_turnout_`type' "Mean Voter Turnout, `type'"
}

bysort year SMD_margin_quantile: egen mean_turnout_DT=mean(turnout_DT)

gen m="m"
gen w="w"


*look at socialst vote in Q6


sort SMD_district year 
foreach party in lib soc con other {
gen share_`party'=`party'_final/castedvotesoverall
gen ch_share_`party'=share_`party'-l3.share_`party'
}

lab define quantiles 1 "Most Competitive" 6 "Least Competitive"
lab values SMD_margin_quantile quantiles

***********************
*Figure A10: Figure Quantile, Turnout change, Socialist vote share change
*************************
# delimit ; 
twoway (scatter ch_turnoutmen_DT ch_share_soc,  msym(Oh) mcolor(navy)) 
(scatter ch_turnoutwomen_DT ch_share_soc, msym(Oh) mcolor(magenta))
(lfit ch_turnoutmen_DT  ch_share_soc, lwidth(thick) lpattern(solid) lcolor(blue))
(lfit ch_turnoutwomen_DT  ch_share_soc, lwidth(thick) lpattern(solid) lcolor(magenta))  if year==1921, by(SMD_margin_quantile, note("") legend(off)) scheme(tufte) xtitle("Change in Socialist/Labour Share of the Vote 1921-1918") yline(0, lcolor(red)) ytitle("Change in Turnout 1921-1918");


graph export "../images/FigA10.eps", replace; 

**************************************************************
*Fig A 11: Quantile 6 women's vote share party 
**************************************************************

# delimit ; 
twoway (scatter ch_turnoutwomen_DT ch_share_lib,  msym(Oh) mcolor(green)) 
(scatter ch_turnoutwomen_DT ch_share_soc, msym(Oh) mcolor(red))
(scatter ch_turnoutwomen_DT ch_share_con, msym(Oh) mcolor(navy ))

(lpoly ch_turnoutwomen_DT ch_share_lib,  lwidth(thick) lcolor(green))
(lpoly ch_turnoutwomen_DT ch_share_soc, lwidth(thick) lpattern(solid) lcolor(red))
(lpoly ch_turnoutwomen_DT ch_share_con, lwidth(thick) lcolor(navy ))

 if year==1921 & SMD_margin_quantile==6,  scheme(tufte) xtitle("Change in Party Vote Share 1921-1918") yline(0, lcolor(red)) ytitle("Change in Women's Turnout 1921-1918") legend(label(4 "Liberal") label(5 "Labour") label(6 "Conservative") row(1) order(4 5 6)) title("Quantile 6, Previously Uncompetitive");



graph export "../images/FigA11.eps", replace

